/*
 * Copyright (c) zhg2yqq.com Corp.
 * All Rights Reserved.
 */
package com.zhg2yqq.wheels.common.exception;

import com.zhg2yqq.wheels.common.response.IResponseCode;

/**
 * @author zhg2yqq, 2022年12月14日
 * @version zhg2yqq v1.0
 */
public class BusinessException extends BaseException {
    private static final long serialVersionUID = 1L;

    BusinessException(String code) {
        super(code);
    }

    public static BusinessException of(String code) {
        BusinessException ex = new BusinessException(code);
        ex.setDefaultMessage(code);
        return ex;
    }

    public static BusinessException of(String code, Object... parameters) {
        BusinessException ex = new BusinessException(code);
        ex.setDefaultMessage(code);
        ex.setParameters(parameters);
        return ex;
    }

    public static BusinessException of(IResponseCode responseCode) {
        BusinessException ex = new BusinessException(responseCode.getCode());
        ex.setDefaultMessage(responseCode.getDescription());
        return ex;
    }

    public static BusinessException of(IResponseCode responseCode, Object... parameters) {
        BusinessException ex = new BusinessException(responseCode.getCode());
        ex.setDefaultMessage(responseCode.getDescription());
        ex.setParameters(parameters);
        return ex;
    }
}
